all: rover

rover: libs server_ rover-computer_ server-arduino_ rover-arduino_

server_:
	make -C $(RVR_ROOT)/server

rover-computer_:
	make -C $(RVR_ROOT)/rover-computer

server-arduino_:
	make -C $(RVR_ROOT)/server-arduino

rover-arduino_:
	make -C $(RVR_ROOT)/rover-arduino

libs: port_comm serial_comm util joystick configs

configs:
	make lib -C $(RVR_ROOT)/config

joystick:
	make lib -C $(RVR_ROOT)/joystick_lib

port_comm:
	make lib -C $(RVR_ROOT)/comm_libs/port_comm

serial_comm:
	make lib -C $(RVR_ROOT)/comm_libs/serial_comm

util:
	make lib -C $(RVR_ROOT)/util_lib

stream:
	make -C $(RVR_ROOT)/streaming

clean: clean-libs
	make clean -C $(RVR_ROOT)/server
	make clean -C $(RVR_ROOT)/rover-computer
	make clean -C $(RVR_ROOT)/server-arduino
	make clean -C $(RVR_ROOT)/rover-arduino
	make clean -C $(RVR_ROOT)/joystick_lib
	make clean -C $(RVR_ROOT)/config

clean-libs:
	make clean -C $(RVR_ROOT)/comm_libs/port_comm
	make clean -C $(RVR_ROOT)/comm_libs/serial_comm
	make clean -C $(RVR_ROOT)/util_lib

clean-stream:
	make clean -C $(RVR_ROOT)/streaming

run-server:
	make run -C $(RVR_ROOT)/server

run-rover:
	make run -C $(RVR_ROOT)/rover-computer

run-server-camera1:
	make run1 -C $(RVR_ROOT)/streaming/UDP2/server

run-server-camera2:
	make run2 -C $(RVR_ROOT)/streaming/UDP2/server

run-server-high-quality:
	make run -C $(RVR_ROOT)/streaming/frame/server

run-rover-camera1:
	make run -C $(RVR_ROOT)/streaming/UDP2/rover

run-rover-camera2:
	make run -C $(RVR_ROOT)/streaming/UDP3/rover

run-rover-high-quality:
	make run -C $(RVR_ROOT)/streaming/frame/rover

usb:
	sudo modprobe -r xhci_hcd
	sudo modprobe xhci_hcd

setup-server:
	make usb
	make upload -C $(RVR_ROOT)/server-arduino

setup:
	make usb
	make upload -C $(RVR_ROOT)/rover-arduino

